package com.carlinfo.stu_ques.users.dao.impl;

import java.io.File;

import java.util.List;
import java.util.Map;

import com.carlinfo.stu_ques.common.dao.impl.BaseDaoImpl;
import com.carlinfo.stu_ques.users.dao.IStudentDao;
import com.carlinfo.stu_ques.users.pojo.Students;

public class StudentDaoImpl extends BaseDaoImpl<Students> implements IStudentDao
{
	private File resultfile = new File(this.parentFile, "studentSource.dat");

	/**
	 * 无参的构造函数，被实例化时先运行，将其中的值取出来
	 */
	public StudentDaoImpl()
	{
		this.readFile(resultfile);
	}

	/**
	 * 存储一条学生
	 */
	@Override
	public int saveOneDao(Students stu)
	{
		stu.setId(this.id);
		tempId = stu.getId();
		super.saveOneDao(stu);
		this.writeFile(resultfile);
		return this.tempId;
	}

	/**
	 * 更新一条记录
	 */
	@Override
	public void updateOneDao(Students stu)
	{

		this.tempId = stu.getId();
		super.updateOneDao(stu);
		this.writeFile(resultfile);
	}

	/**
	 * 删除一条记录
	 */
	@Override
	public void deleteOneDao(Students stu)
	{
		this.tempId = stu.getId();
		super.deleteOneDao(stu);
		this.writeFile(resultfile);
	}

}
